<?php
/**
 * 解决跨域问题
 */
header("Access-Control-Allow-Origin: *");//允许所有地址跨域请求
function post($url,$data){
	$curl = curl_init();
	curl_setopt_array($curl, array(
	  CURLOPT_URL => $url,
	  CURLOPT_RETURNTRANSFER => true,
	  CURLOPT_ENCODING => "",
	  CURLOPT_MAXREDIRS => 10,
	  CURLOPT_TIMEOUT => 30,
	  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
	  CURLOPT_CUSTOMREQUEST => "POST",
	  CURLOPT_POSTFIELDS => http_build_query($data),
	  CURLOPT_HTTPHEADER => array(
		"Content-Type:application/x-www-form-urlencoded"
	  ),
	));
	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); //验证curl对等证书(一般只要此项)
	curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); //检查服务器SSL证书中是否存在一个公用名
	curl_setopt($curl, CURLOPT_SSLVERSION, 0); //传递一个包含SSL版本的长参数。
	$response = curl_exec($curl);
	$err = curl_error($curl);
	curl_close($curl);
	if ($err) {
	  return '{"code":1,"msg":系统错误：'.$err.'}';
	} else {
	  return $response;
	}
}
if(!isset($_POST['url'])||!isset($_POST['data'])){
	exit('参数错误哦！');
}
echo post($_POST['url'],$_POST['data']);